<?php
// instacia Objeto "conexao".
$mysql = new conexao;
/**
* 
* Fazendo a consulta
* 
*/
$portfoliolista = $mysql->sql_query(
"
select p.*, c.nome_categoria,img.nome, img.extensao 
				from portfolio p
				LEFT JOIN portfolio_para_categorias pc
					ON pc.portfolio_id_portfolio=p.id_portfolio
				LEFT JOIn categorias c
					ON c.id_categoria=pc.categorias_id_categoria
				LEFT JOIN imagens img 
					ON img.portfolio_id_portfolio = p.id_portfolio 
                                        
				group by p.id_portfolio
                                LIMIT 5
				
"
);

 ?>
<div class="sidebar">
	<h1>Categorias</h1>
	<ul>
                <li class="residencial"><a href="?p=portfolio&id=1">Residencial</a></li>
                <li class="restaurante"><a href="?p=portfolio&id=2">Restaurantes e Fast Foods</a></li>
                <li class="corporativo"><a href="?p=portfolio&id=3">Corporativos</a></li>
                <li class="lojas"><a href="?p=portfolio&id=4">Lojas</a></li>
                <li class="hospitalares"><a href="?p=portfolio&id=5">Hospitalares</a></li>
	</ul>
	<h1>Últimos projetos</h1>
	<div class="ultimosProjetos">
		<?php 
		while($portfolio = mysql_fetch_object($portfoliolista)){
		?>
		<div class="boxprojects">
                    <a href="./?p=portfolio&idPort=<?php echo $portfolio->id_portfolio ?>">
			<img src="../cms/uploads/portfolio/<?php echo $portfolio->nome; echo $portfolio->extensao ?>" alt="" title="">
                    </a>
                    <h2>
                        <a href="./?p=portfolio&idPort=<?php echo $portfolio->id_portfolio ?>">
                            <?php echo $portfolio->nome_projeto ?>	
                        </a>
                    </h2>
		</div>
	<?php } ?>	
	</div>
	<span>
	 <a href="./?p=portfolio">Ver todos projetos</a>
	</span>
</div>